#ifndef RATIONAL
#define RATIONAL

class Rational
{
public:
	explicit Rational(int n = 0, int d = 1);
	Rational(const Rational&);
	
	Rational& operator= (const Rational& b);
	Rational& operator+= (const Rational& b);
	Rational& operator-= (const Rational& b);
	Rational& operator*= (const Rational& b);
	Rational& operator/= (const Rational& b);

	operator double () const;

	friend bool operator== (const Rational& a, const Rational& b);
	friend bool operator<  (const Rational& a, const Rational& b);
	friend bool operator>  (const Rational& a, const Rational& b);

	int numerator() const { return _numerator; }
	int denominator() const { return _denominator; }

private:
	void reduce();

private:
	int _numerator;
	int _denominator;
};

Rational operator+ (const Rational& a, const Rational& b);
Rational operator- (const Rational& a, const Rational& b);
Rational operator- (const Rational& a);
Rational operator* (const Rational& a, const Rational& b);
Rational operator/ (const Rational& a, const Rational& b);

bool operator== (const Rational& a, const Rational& b);
bool operator!= (const Rational& a, const Rational& b);
bool operator<= (const Rational& a, const Rational& b);
bool operator>= (const Rational& a, const Rational& b);
bool operator<  (const Rational& a, const Rational& b);
bool operator>  (const Rational& a, const Rational& b);


#endif